<template>
	<uni-nav-bar
		shadow
		fixed
		left-icon="left" 
		left-text="返回"
		color="#fff"
		statusBar
		background-color="#3c9cff" 
		:title="title"
		@clickLeft="leftClick"
	/>
</template>

<script>
	import pages from '@/pages.json'
	export default {
		props:{
			title:String,
			path:String
		},
		methods:{
			leftClick(){
				if(this.path){
					if(!this.getIsTab(this.path)){
						this.$Router.replace(this.path)
					}else{
						this.$Router.pushTab(this.path) //返回路由为Tab时
					}
				}else{
					this.$Router.back()
				}
			},
			getIsTab(currPath){
				return !! pages.tabBar.list.find((e) =>'/'+ e.pagePath === currPath)
			}
		}
	}
</script>
